package org.subatu.orm.service.base;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.subatu.orm.query.base.SqlStruct;


public interface SqlQuery extends ConditionAndOrder, BaseQuery {

    Logger logger = LoggerFactory.getLogger("SQL");

    default SqlStruct buildSql() {
        // String selectSql = this.buildSelectSql();
        String selectSql = "select * ";
        // logger.info("selectSql = " + selectSql);
        String fromSql = this.buildFromSql();
        // logger.info("fromSql = " + fromSql);
        String whereSql = this.buildWhereSql();
        // logger.info("whereSql = " + whereSql);
        String orderBySql = this.buildOrderBySql();
        // logger.info("最终的参数值: valueList = " + valueList);

        StringBuilder sql = new StringBuilder();
        sql.append(selectSql);
        sql.append(fromSql);
        sql.append(whereSql);
        sql.append(orderBySql);
        sql.append(sqlData().lastSql);
        logger.info("得到sql-->\n{}\n参数:{}", sql.toString(), sqlData().valueList);

        return new SqlStruct(sql.toString(), sqlData().valueList);
    }


}
